/**
 * 
 */
package com.exam.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.exam.boImpl.StudentBoImpl;
import com.exam.exambo.IStudentBo;
import com.exam.model.Student;
import com.opensymphony.xwork2.ActionSupport;

/**
 * @author adminpro
 * 
 */
@Component
public class StudentAction extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;


	private IStudentBo studBo;
	@Autowired
	public void setStudBo(IStudentBo studBo) {
		this.studBo = studBo;
	}
	
	private Student std;	
	
	
	List<Student> lstStudent;
	
	

	/**
	 * @return the std
	 */
	public Student getStd() {
		return std;
	}

	/**
	 * @param std the std to set
	 */
	public void setStd(Student std) {
		this.std = std;
	}

	/**
	 * @return the lstStudent
	 */
	public List<Student> getLstStudent() {
		return lstStudent;
	}

	/**
	 * @param lstStudent the lstStudent to set
	 */
	public void setLstStudent(List<Student> lstStudent) {
		this.lstStudent = lstStudent;
	}

	public String getList() {
		try {
			lstStudent = studBo.getList();
		} catch (Exception e) {
			addActionError("Error Load");
			return ERROR;
		}
		return SUCCESS;
	}

	public String updateStudent() {
		try {
			studBo.updateStudent(std);
		} catch (Exception e) {
			return ERROR;
		}
		return SUCCESS;
	}
	
	public String addStudent()
	{
		try {			
			studBo.addStudent(std);
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
		return SUCCESS;
	}
}
